package com.czk.practice.server.handler;

import com.czk.practice.domain.Message2;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/8/19 15:19
 */
public class MyHandler2 extends SimpleChannelInboundHandler<Message2> {
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, Message2 message2) throws Exception {
        //
        System.out.println("服务器收到，其字节码是" + message2.getClass().getName());
        // 内容是
        System.out.println("msg2=" + new String(message2.getContent()));
        Message2 msg2 = new Message2();
        msg2.setContent("nzq".getBytes());
        msg2.setLen(msg2.getContent().length);
        channelHandlerContext.writeAndFlush(msg2);
    }
}
